package com.qcby.controller;

import com.qcby.entity.ExploreScript;
import com.qcby.entity.PageResult;
import com.qcby.entity.Query.ExploreScriptQuery;
import com.qcby.entity.Result;
import com.qcby.entity.Shop;
import com.qcby.service.ExploreScriptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/exploreScript")
public class ExploreScriptController {
    @Autowired
    private ExploreScriptService exploreScriptService;
    @RequestMapping("/list")
    public Result list(ExploreScriptQuery exploreScriptQuery){
        System.out.println(exploreScriptQuery+"输入的参数时");
        PageResult<ExploreScript> list = exploreScriptService.list(exploreScriptQuery);
        return Result.success(list);
    }
    @RequestMapping("/deleteById")
    public Result deleteById(Integer id){
        exploreScriptService.deleteById(id);
        return Result.success();
    }
    @RequestMapping("/getById")
    public Result getById(Integer id){
        System.out.println(id+"输入的id");
        ExploreScript exploreScript = exploreScriptService.getById(id);
        return Result.success(exploreScript);
    }
    @RequestMapping("/getByIds")
    public Result getByIds(@RequestBody Integer[] ids){
        System.out.println(Arrays.toString(ids)+"输入的id");
        List<Shop> exploreScript = exploreScriptService.getByIds(ids);
        return Result.success(exploreScript);
    }
    @RequestMapping("/add")
    public Result add(ExploreScriptQuery exploreScriptQuery) throws IOException {
        List<ExploreScript> list = exploreScriptService.add(exploreScriptQuery);
        return Result.success(list);
    }
}
